/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // 配置跨域请求白名单
  config.security = {
    csrf: {
      // 前后端分离，post请求不方便携带_csrf  
      enable: false,
      ignoreJSON: true
    },
    // 配置白名单
    domainWhiteList: ['192.168.1.4', '192.168.1.5', '127.0.0.1', 'localhost'],
  };
  config.cors = {
    //允许所有跨域访问，注释掉则允许上面 白名单 访问 
    // origin: '*',
    // 允许跨域请求携带cookies 
    credentials: true,
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  };
  config.cluster = {  listen: {    port: 8890,    hostname: '0.0.0.0',  }};
  exports.logger = {
    // 日志文件夹路径, 对应的路径是和app.js同级别;
    dir: './myLog',
    level: 'NONE',
  };

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1626155083599_2472';

  // add your middleware config here
  /*config.middleware = ['security', 'jwt'];
  config.jwt = {
    match: [ '/owner/!*' ]
  };*/


  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
